<template>
  <div>
    <h2>上传组件</h2>
    <el-upload
      name="file"
      class="upload-demo"
      drag
      accept=".apk"
      v-show="pkg.packageName == ''"
      v-bind:action="uploadUrl"
      multiple
      :on-success="uploadSuccess"
      :on-error="uploadError"
      :before-upload="beforeUpload"
    >
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">
        将APK文件拖到此处，或
        <em>点击上传</em>
      </div>
      <div class="el-upload__tip" slot="tip">只能上传APK,不超过200MB</div>
    </el-upload>
  </div>
</template>

<script>
export default {
  props: {
    msg: String,
    count: Number,
    baseData: Object,
  },
  data: function () {
    return {
      apkInfoUrl: this.$Global.host + ":8081/banana/apk-info",
      uploadUrl: this.$Global.host + ":8081/banana/upload",
    };
  },
  methods: {
    resetData: function () {
      Object.assign(this.$data, this.$options.data());
    },
    uploadSuccess: function (response, file, fileList) {
      console.log("Upload complete!" + response);
      console.log(fileList);
      this.loading = false;
      this.getApkInfo(response);
    },
    uploadError: function (err, file, fileList) {
      console.log("error: " + err + file);
      console.log(fileList);
      this.loading = false;
      this.showMsg(err);
    },
    beforeUpload: function () {
      this.loading = true;
    },
  },
};
</script>

<style>
</style>